comparing attribute definitions

Hi all,

does anybody know of a simple/easy way to compare attribute definitions between modules?
I want to be able to tell if the attribute definitions (type, scope, enum values, etc.) in a given module are identical with the attribute definitions in a reference module.

Karl
kabr - Thu Apr 04 05:21:54 EDT 2013

Re: comparing attribute definitions
llandale - Thu Apr 04 13:27:12 EDT 2013

Something like this, but you need to add your own error reporting.

bool IsAttrSame(string in_NameAttr, Module in_mReference, in_mLive)
{   // Is this attribute defined the same in both the Reference and Live modules?
 
  AttrDef adR = find(in_mReference, in_NameAttr)
  AttrDef adL = find(in_mLive, in_NameAttr)
  
  bool Same = true
  if ( null adR and  null adL) then { Neither exists; return(false)}
  if ( null adR and !null adL) then { adL only exists; return(false)}
  if (!null adR and  null adL) then { adR only exists; return(false)}
       // both exist:
  if (adR.typeName != adL.typeName) {type mismatch; Same = false}
  if (adR.multi != adL.multi) {multi mismatch; Same = false}
  if (adR.(bool defval) != adL.(bool defval) ) {HasDefault  mismatch; Same = false}
  if (adR.(string defval) != adL.(string defval) ) {Default Value  mismatch; Same = false}
       // I have doubts about the above line.
... ditto for nobars, nochanges, nohistory, inherit, bool dxl, string dxl, module, object,
           description, and I suppose: canWrite, useraccess, system, hidden.
 
   phew.
 
   return(Same)
} // end IsAttrSame()
 
Skip skpNames = createString() // KEY and DATA both 'string' NameAttr
for Name in mReference do {put(skpNames, Name, Name)}
for Name in mLive do {put(skpNames, Name, Name)
for Name in skpNames do
{  IsSameAttr(mReference, mLive, Name)
}
delete(skpNames)


-Louie

Re: comparing attribute definitions
kabr - Fri Apr 05 08:37:16 EDT 2013

llandale - Thu Apr 04 13:27:12 EDT 2013

Something like this, but you need to add your own error reporting.

bool IsAttrSame(string in_NameAttr, Module in_mReference, in_mLive)
{   // Is this attribute defined the same in both the Reference and Live modules?
 
  AttrDef adR = find(in_mReference, in_NameAttr)
  AttrDef adL = find(in_mLive, in_NameAttr)
  
  bool Same = true
  if ( null adR and  null adL) then { Neither exists; return(false)}
  if ( null adR and !null adL) then { adL only exists; return(false)}
  if (!null adR and  null adL) then { adR only exists; return(false)}
       // both exist:
  if (adR.typeName != adL.typeName) {type mismatch; Same = false}
  if (adR.multi != adL.multi) {multi mismatch; Same = false}
  if (adR.(bool defval) != adL.(bool defval) ) {HasDefault  mismatch; Same = false}
  if (adR.(string defval) != adL.(string defval) ) {Default Value  mismatch; Same = false}
       // I have doubts about the above line.
... ditto for nobars, nochanges, nohistory, inherit, bool dxl, string dxl, module, object,
           description, and I suppose: canWrite, useraccess, system, hidden.
 
   phew.
 
   return(Same)
} // end IsAttrSame()
 
Skip skpNames = createString() // KEY and DATA both 'string' NameAttr
for Name in mReference do {put(skpNames, Name, Name)}
for Name in mLive do {put(skpNames, Name, Name)
for Name in skpNames do
{  IsSameAttr(mReference, mLive, Name)
}
delete(skpNames)


-Louie

Many thanks, Louie,

that's what I feared.
I was sort of hoping there was a simpler way than to write my own compare function, because I assume that there's something similar going on when you import attributes from another module.

Thanks again.
Karl